Skip to content

Conversation

@edmondchuc
Copy link
Contributor

@edmondchuc edmondchuc commented Nov 7, 2025

Summary of changes

This PR introduces a httpx-based RDF4J Client that wraps the RDF4J REST API and implements an RDF4J Store (#3316).

Where possible, it provides tight integration with RDFLib by returning RDFLib data objects for graphs, datasets, and SPARQL results.

Majority of the code is in rdflib.contrib.rdf4j.client. The codebase is covered by unit tests (with mocks) and end-to-end test with testcontainers, which spins up real GraphDB instances. I've tried to document what I can with docstrings, but I will add user-facing documentation soon.

The main classes to note:

  • RDF4JClient - the main entrypoint to using this package.
  • RepositoryManager - manage repositories at the server-level
  • Repository - manages an individual repository
    • NamespaceManager - manage a repository's namespace prefixes
    • GraphStoreManager - a repository's graph store protocol interface
    • Transaction - a transaction manager for a repository

Notes

A small bit of GraphDB specific code is included in the PR but please ignore it for now. This is incomplete and only here to showcase how we'd implement some GraphDB specific handling on top of RDF4J. This will be a separate piece of work in a separate PR.

I had to add in the python version upper bound <4.0 in pyproject.toml as it's required by testcontainers. We can remove this upper bound once testcontainers relaxes this constraint in testcontainers/testcontainers-python#909.

This is now resolved with the release of python testcontainers 4.13.3.

Next steps

  • I will be working on an RDFLib Store implementation next that wraps the RDF4J Client in a separate PR.
    • Update: this PR is available here feat: RDF4J store #3316
    • Update again: the RDF4J Store PR has since been merged into this PR
  • Usage documentation and examples

Checklist

  • Checked that there aren't other open pull requests for
    the same change.
  • Checked that all tests and type checking passes.
  • If the change adds new features or changes the RDFLib public API:
    • Created an issue to discuss the change and get in-principle agreement.
    • Considered adding an example in ./examples.
  • If the change has a potential impact on users of this project:
    • Added or updated tests that fail without the change.
    • Updated relevant documentation to avoid inaccuracies.
    • Considered adding additional documentation.
  • Considered granting push permissions to the PR branch,
    so maintainers can fix minor issues and keep your PR up to date.

# Conflicts:
#	poetry.lock
…, add overwrite and get methods on Repository class and add tests for them
Also fixes a httpx limitation with key-only query params.
@nicholascar nicholascar self-requested a review November 7, 2025 03:09
@edmondchuc
Copy link
Contributor Author

Adding a comment here to remind myself to add httpx to the docs dependencies. The absence of httpx is causing MkDocs to not generate certain pages related to RDF4J modules.

@edmondchuc edmondchuc mentioned this pull request Nov 14, 2025
8 tasks
* fix: handle graph_name when it's a str

* feat: wip RDF4JStore

Implements:

- init/open
- close
- add
- addN
- contexts
- add_graph
- remove_graph
- __len__

* feat: RDF4J Store now supports handling namespaces and prefixes

* feat: RDF4J Store triples and quads querying

* feat: ensure no bnodes are used to cross document/query boundaries

* chore: formatting

* test: improve e2e test speed by reusing the same container and cleaning up the repo between each tests

* feat: add RDF4JStore remove

* feat: add RDF4JStore triples_choices tests

* feat: add RDF4JStore SPARQL query and update tests

* chore: fix mypy issues

* test: error handling on client fixture

* test: mark testcontainer tests and put test imports behind the has_httpx flag

* build: remove upper python bound, bump testcontainers, and revert back to stable v7 poetry.lock

* test: put testcontainer tests behind a flag for unsupported python versions

* test: install rdf4j extras for python 3.9 and above

* ci: skip testcontainer tests on non-linux runners
@edmondchuc
Copy link
Contributor Author

Merging the RDF4J store PR #3316 should now fix the tests here.

Reminding myself here that I still need to rename the NamespaceManager class.

@edmondchuc
Copy link
Contributor Author

Note that the end-to-end tests using testcontainers only run on the Linux runners in GitHub Actions. Additionally, testcontainers is only installed on python 3.9+.

@nicholascar nicholascar merged commit b71e2ae into 7.x Nov 14, 2025
29 checks passed
@nicholascar nicholascar deleted the v7/feat/rdf4j branch November 14, 2025 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants